import type {
  IGetCodeData,
  IGetCodeParams,
  LoginCodeData,
  LoginCodeParams,
  LoginDataType,
  LoginParams,
  UserData,
} from '@/types/user'
import request from '@/utils/request'

export const LoginByPasswordAPI = (data: LoginParams) => {
  return request.post<null, LoginDataType>('/login/password', data)
}

/** 获取验证码的API函数 */
export const getCodeAPI = (params: IGetCodeParams) => {
  return request.get<null, IGetCodeData>(`/code`, { params })
}

/**
 * 用户登录接口（短信验证码方式）
 */
export const loginByMobileAPI = (data: LoginCodeParams) => {
  return request.post<null, LoginCodeData>('/login', data)
}

export const loginByWXAPI = (data: any) => {
  return request.post('/login/wxMin', data)
}

/** 查询个人信息 */
export const getUserInfoApi = () => {
  return request.get<null, UserData>('/patient/myUser')
}
